<template>
  <div class="gd">
    <div class="itemList">
      <div class="item" v-for="(item, i) in itemList" :key="i">
        <div class="itemLeft" @click="playMusic(i)">
          <span class="leftSpan">{{ i + 1 }}</span>
          <div>
            <p>{{ item.name }}</p>
            <span
              class="itemname"
              v-for="(item1, index) in item.ar"
              :key="index"
              >{{ item1.name }}</span
            >
          </div>
        </div>
        <div class="itemRight">
          &times;
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapMutations} from "vuex"
export default {
  props:["itemList"],
  data() {
    return {
      i: null,
    }
  },
  computed: {
    // ...mapState(["itemList"])
  },
  updated () {
    this.playMusic();
  },
  mounted() {
    console.log("音乐列表:", this.itemList)
    this.playMusic()
  },
  methods: {
    ...mapMutations(["updateplayListIndex1","updateplayList1"]),
    playMusic(i) {
      // this.updatePlayListIndex(i)
      // this.updateplayList1(this.itemList)
      this.updateplayListIndex1(i)
    },
  },
}
</script>

<style lang="scss" scoped>
.gd {
  padding: 10px;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}
.itemList {
  padding: 10px;

  .item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;

    .itemLeft,
    .itemRight {
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 14px;

      .leftSpan {
        padding: 10px;
        font-size: 12px;
      }

      .itemname {
        color: #666;
        font-size: 10px;
      }
    }
  }
}
</style>
